package com.oop1;



/**
 * 理解多态
 *什么是多态：
 * 1.父类引用 引用子类对象
 * 2.父类与子类有同名的覆盖方法
 * 3.通过父类引用去调用重写的方法（运行时绑定）
 */

class Shape{
    public void draw(){

    }
}

class Cycle extends  Shape{
    @Override
    public void draw() {
        System.out.println("画一个圆圈");
    }
}

class React extends Shape{
    @Override
    public void draw() {
        System.out.println("画一个矩形");
    }
}



public class DuoTai {
    public  static void drawMap(Shape shape){
        shape.draw();
    }
    public static void main(String[] args) {
        Shape shape1 = new Cycle();
        Shape shape2 = new React();
        drawMap(shape1);
        drawMap(shape2);
    }
}

